const Sequelize = require("sequelize");
const sequelize = require("../dbConn.js");

const { STRING, INTEGER, DATE, BIGINT, TEXT } = Sequelize;

class TableModel extends Sequelize.Model{}
class TableData extends Sequelize.Model{}
class DialogItem extends Sequelize.Model{}
class Devices extends Sequelize.Model{}
class Factory extends Sequelize.Model{}
class DeviceTypes extends Sequelize.Model{}
class Levels extends Sequelize.Model{}

TableModel.init({
    id: {
        type: STRING,
        allowNull: false,
        primaryKey: true,
        unique: true
    },
    column: STRING,
    prop: STRING,

},{
    sequelize,
    modelName: "TableModel"
});

TableData.init({
    id: {
        type: STRING,
        allowNull: false,
        primaryKey: true,
        unique: true
    },
    company: STRING,
    name: STRING,
    type: STRING,
    level: STRING,
},{
    sequelize,
    modelName: "TableData"
});

DialogItem.init({
    field: {
        type: STRING,
        allowNull: false,
        primaryKey: true,
        unique: true
    },
    type: STRING,
    id: STRING,
    pid: STRING,
    name: STRING,
    value: STRING,
    required: STRING,
},{
    sequelize,
    modelName: "DialogItem"
});

Devices.init({
    value: {
        type: STRING,
        allowNull: false,
        primaryKey: true,
        unique: true
    },
    name: STRING,
},{
    sequelize,
    modelName: "Devices"
});

Factory.init({
    value: {
        type: STRING,
        allowNull: false,
        primaryKey: true,
        unique: true
    },
    name: STRING,
},{
    sequelize,
    modelName: "Factory"
});

DeviceTypes.init({
    value: {
        type: STRING,
        allowNull: false,
        primaryKey: true,
        unique: true
    },
    name: STRING,
},{
    sequelize,
    modelName: "DeviceTypes"
});

Levels.init({
    value: {
        type: STRING,
        allowNull: false,
        primaryKey: true,
        unique: true
    },
    name: STRING,
},{
    sequelize,
    modelName: "Levels"
});

module.exports = {
    TableModel,
    TableData,
    DialogItem,
    Devices,
    Factory,
    DeviceTypes,
    Levels
};
